/**
 * ImageList.java Create on 2012-7-30     
 *      
 * Copyright (c) 2012-7-30 by yiming     
 *      
 * @author <a href="alenzhangym@hotmail.com">Yiming</a>     
 * @version 1.0 
 */

package com.yimi.service;

import android.os.Parcel;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;

/**
 * TODO ��������
 * 
 * @author Yiming
 * @version 1.0
 */
public class ImageList extends Entity {
    private int size;
    private String searchName;

    private List<BaseImageItem> imageList;
    private int page;

    public ImageList() {
        super();
        imageList = new ArrayList();
    }

    /**
     * @param in
     */
    public ImageList(Parcel in) {
        this.readFromParcel(in);
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public List<BaseImageItem> getImageList() {
        return imageList;
    }

    public void setImageList(List<BaseImageItem> imageList) {
        this.imageList = imageList;
    }

    /*
     * (non-Javadoc)
     * @see android.os.Parcelable#describeContents()
     */
    @Override
    public int describeContents() {
        return 0;
    }

    /*
     * (non-Javadoc)
     * @see android.os.Parcelable#writeToParcel(android.os.Parcel, int)
     */
    public void readFromParcel(Parcel in) {
        Log.e(this.getClass().getName(), "Start to read");
        super.readFromParcel(in);
        size = in.readInt();
        page = in.readInt();
        searchName = in.readString();
        imageList = new ArrayList<BaseImageItem>();
        for (int i = 0; i < size; i++) {
            BaseImageItem baseItem = new BaseImageItem();
            baseItem.readFromParcel(in);
            imageList.add(baseItem);
        }
        Log.e(this.getClass().getName(), "read over");
    }

    public void readToParcel(Parcel in) {
        size = in.readInt();
        page = in.readInt();
        searchName = in.readString();
        imageList = new ArrayList<BaseImageItem>();
        for (int i = 0; i < size; i++) {
            BaseImageItem baseItem = new BaseImageItem();
            baseItem.readToParcel(in);
            imageList.add(baseItem);
        }
    }

    public void writePacel(Parcel dest, int flags) {
        Log.e(this.getClass().getName(), "start to write");
        dest.writeInt(size);
        dest.writeInt(page);
        dest.writeString(searchName);
        for (int i = 0; i < size; i++) {
            imageList.get(i).writePacel(dest, flags);
        }
        Log.e(this.getClass().getName(), "write over");
    }

    /**
     * @return the page
     */
    public int getPage() {
        return page;
    }

    public String getSearchName() {
        return searchName;
    }

    public void setSearchName(String searchName) {
        this.searchName = searchName;
    }

    /**
     * @param page the page to set
     */
    public void setPage(int page) {
        this.page = page;
    }

    public String toString() {
        String result = super.toString();
        result += "page =";
        result += page;
        result += "searchName = ";
        result += searchName;
        result += "size =";
        result += size;
        return result;
    }
}
